package com.joker.order.controller;

import com.joker.common.core.domain.Result;
import com.joker.order.annotation.CheckIdempotent;
import com.joker.order.domain.dto.OrderDTO;
import com.joker.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/placeAnOrder")
    @CheckIdempotent
    public Result<String> placeAnOrder(@RequestBody OrderDTO orderDTO){
        orderService.takeOrder(orderDTO);
        return Result.success(orderDTO.getOrderNo());
    }

    @GetMapping("/getOrderStatus/{orderNo}")
    public Result<Long> getOrderStatus(@PathVariable String orderNo){
        Long orderStatus = orderService.selectOrderStatus(orderNo);
        return Result.success(orderStatus);
    }



}
